/**
 * Created with IntelliJ IDEA.
 * Description:比较版本号
 * User: wangxin
 * Date: 2024-11-03
 * Time: 22:26
 */
public class test {
    public int compare (String version1, String version2) {
        // write code here
        int i = 0,j=0;
        int n1 = version1.length(),n2 = version2.length();
        while(i < n1 || j < n2){
            long num1 = 0;
            while(i < n1&& version1.charAt(i) != '.'){
                num1 = num1* 10 + (version1.charAt(i) - '0');
                i++;
            }
            i++;
            long num2 = 0;
            while(j < n2&& version2.charAt(j) != '.'){
                num2 = num2* 10 + (version2.charAt(j) - '0');
                j++;
            }
            j++;
            if(num1 > num2){
                return 1;
            }else if(num1 < num2){
                return -1;
            }

        }
        return 0;
    }
}
